<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/layui.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/layui.js"></script>
    <script type="text/javascript">
        function check(){
            if (${user.isCold} == 1){
                alert("您的账号已冻结！无法进行此操作。");
                return false;
            }
            var userpassword = document.getElementsByName("userpassword")[0].value;
            var userpassword2 = document.getElementsByName("userpassword2")[0].value;
            var tel = document.getElementsByName("tel")[0].value;

            if (userpassword != userpassword2){
                alert("密码不一致");
                return false;
            }
            if (tel.length!=11 && tel.length!=0){
                alert("请输入11位电话");
                return false;
            }
            return true;
        }
    </script>
    <style>
        form{
            margin-top: 50px;
            padding: 50px;
        }
    </style>
</head>
<body>
<form class="layui-form" onsubmit="return check()" action="${pageContext.request.contextPath}/adduser">
    <div  style="margin: auto auto">
        <div style="font-size: 30px;text-align: center">新增用户</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" maxlength="20" name="username" required autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" maxlength="20" name="userpassword" required placeholder="6-20个字符，空白默认不修改" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">重复密码</label>
        <div class="layui-input-block">
            <input type="text" maxlength="20" name="userpassword2" required placeholder="重复密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" maxlength="11" required oninput = "value=value.replace(/[^0-9.]/g,'')" name="tel" placeholder="电话" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">新增</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <div class="layui-bg-gray">
        <p style="font-size: 30px">${addusermsg}</p>
    </div>
</form>
</body>
</html>
